package zmee.pmgt.pmas.formplugin;

import kd.bos.dataentity.entity.DynamicObject;
import kd.bos.form.plugin.AbstractFormPlugin;
import kd.bos.orm.query.QCP;
import kd.bos.orm.query.QFilter;
import kd.bos.servicehelper.QueryServiceHelper;

import java.math.BigDecimal;
import java.util.EventObject;

/**
 * @author: HeLang
 * @since: 2023/11/21 14:27
 * @description: 立项信息调整单带出原项目概算总额
 */

public class ProApprovalAdjustFormPlugin extends AbstractFormPlugin {


    @Override
    public void afterCreateNewData(EventObject e) {
        super.afterCreateNewData(e);
        Object projApprovalId = this.getView().getFormShowParameter().getCustomParam("projApprovalId");
        if (projApprovalId != null) {
            // 2023年11月21日 11点54分 优化去项目立项中的 项目概算（元）projcetbugamt
            DynamicObject proApproval = QueryServiceHelper.queryOne("pmas_pro_approval", "projcetbugamt", new QFilter("id", QCP.equals, projApprovalId).toArray());
            if (proApproval != null) {
                BigDecimal projectBugAmt = proApproval.getBigDecimal("projcetbugamt");
                this.getModel().setValue("zmee_oldprojectplanamt", projectBugAmt);
            }
        }

    }
}
